<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <#assign currentMenu="comment"/>
    <#include "../common/header.ftl">
    <script src="/js/plugins/jquery-bootstrap/jquery.bootstrap.min.js"></script>
    <script src="/js/My97DatePicker/WdatePicker.js"></script>
    <style type="text/css">
        .modal-body {
            max-height: 750px;
            overflow-y: auto;
        }
        .modal-body img {
            width: 100%;
        }
    </style>
</head>
<body>

<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl">
    <div class="row">
        <div class="col-lg-3">
            <#include "../common/menu.ftl">
        </div>
        <div class="col-lg-9">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-head-line">点评管理</h1>
                </div>
            </div>
            <#--高级查询--->
            <form class="form-inline" id="searchForm" action="/comment/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label>关键字:</label>
                    <input type="text" class="form-control" name="keyword" value="${(qo.keyword)!}"
                           placeholder="请输入标题/副标题">
                </div>

                <button id="btn_query" class="btn btn-info">
                    <span class="glyphicon glyphicon-search"></span> 查询
                </button>
            </form>

            <table class="table table-striped table-hover">
                <tr>
                    <th>序号</th>
                    <th>星级</th>
                    <th>内容</th>
                    <th>点评者</th>
                    <th>攻略标题</th>
                    <th>发布时间</th>
                    <th>操作</th>
                </tr>
                <#list pageInfo.list as entity>
                    <tr>
                        <td>${entity_index + 1}</td>
                        <td>${entity.star}</td>
                        <td>${entity.content}</td>
                        <td>${entity.getUNickName()}</td>
                        <td>${entity.getSTitle()}</td>
                        <td>${(entity.releaseTime?string("yyyy-MM-dd HH:mm:ss"))!}</td>
                        <td>
                            <a role="button" class="btn btn-warning btn-xs inputBtn" data-json='${entity.json}'>
                                <span class="glyphicon glyphicon-pencil"></span> 查看内容
                            </a>
                            <a role="button" class="btn btn-danger btn-xs deleteBtn" data-cid='${entity.id}'>
                                <span class="glyphicon glyphicon-trash"></span> 删除
                            </a>
                        </td>
                    </tr>
                </#list>
            </table>
            <#include "../common/page.ftl">
        </div>
    </div>
</div>
<script>
    $(".deleteBtn").click(function () {
        var id = $(this).data("cid")
        console.log(id);
        $.get("/comment/delete.do",{id:id},function (data) {
            window.location.reload();
        })
    })
</script>

<#-- 修改日报 -->
<div id="inputModal" class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">内容</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" method="post"
                      enctype="multipart/form-data" id="editForm">
                    <div class="form-group">
                        <label class="col-lg-4 control-label">图片：</label>
                        <div class="col-lg-6" id="pics">
                            <img  style="width: 100%"/>
                        </div>
                    </div>
                    <label class="col-lg-4 control-label">内容：</label>
                    <div class="form-group">
                        <textarea name="content" id="ckeditor"></textarea>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
<script src="/js/ckeditor/ckeditor.js"></script>
<script type="text/javascript">
    $(function () {
        $(".inputBtn").click(function () {
            console.log("1");
            var json = $(this).data("json");
            console.log(json);
            if (json) {
                $.each(json.singlePic,function (index, item) {
                    $("<img src="+item.pic+" style=\"width: 100%\"/>").appendTo("#pics")
                })
                $("#editForm [name='content']").html(json.content);
            }
                $("#inputModal").modal('show');

            });
    });
</script>
</body>
</html>